package afcp.alumni.util;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Conf {
	
	public static final Charset DEFAULT_CHARSET = Charsets.UTF8.getCharset();
	public static final String DEFAULT_CHARSET_NAME = Charsets.UTF8.getName();

	private static final Log logger = LogFactory.getLog(Conf.class);

	private static final String CONFIGURATION_FILE = "config.properties";
	private static Conf instance = null;
	private Conf() {
		try {
			config.load(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(CONFIGURATION_FILE), DEFAULT_CHARSET));
		} catch (IOException e) {
			logger.fatal("Cannot load the configuration file " + CONFIGURATION_FILE + "!!", e);
		}
	}
	protected static Conf getInstance() {
		if (instance == null) {
			instance = new Conf();
		}
		return instance;
	}
	
	Properties config = new Properties();
	
	public static String get(String key) {
		return getInstance().config.getProperty(key);
	}

}
